<template>
    <div class="content">
        <div class="grade-top">
            <span>考试次数: {{params.total}}</span>
            <span>平均分: {{sXSore.avg}}</span>
            <span>权重: {{sXSore.weight}}</span>
            <span>计算得分: {{sXSore.scores}}</span>
        </div>
        <div class="clearfix">
            <Form class="f-fl" inline :label-width="5">
                <FormItem>
                    <Input
                        v-model="params.trainingName"
                        placeholder="实训名称"
                    ></Input>
                </FormItem>
                <FormItem>
                    <Button type="primary" @click="search">搜索</Button>
                </FormItem>
                <FormItem>
                    <Button @click="clearSearch">清空</Button>
                </FormItem>
            </Form>

        </div>
        <Table :data="list" :columns="columns" border align="center">
            <template slot-scope="{ row }" slot="action">
                <div class="table-action">
                    <Button :disabled ="row.status==1||row.status==2" type="text" @click="ckTrain(row)">查看实训</Button>
                </div>
            </template>
        </Table>
        <Pagination
            :pageSize.sync="params.pageSize"
            :current.sync="params.pageNum"
            :total="params.total"
            @change="queryList"
        />
    </div>
</template>
<script>
import { trainGradeList } from '@/api/studentExam'

export default {
    inject: ['nextPageReload'],
    data () {
        return {
            sXSore: {},
            roleType: '',
            schoolList: [],
            params: {
                trainingName: '',
                pageNum: 1,
                pageSize: 10,
                total: 0
            },
            list: [],
            columns: Object.freeze([
                { title: '序号', type: 'index', align: 'center', width: 80 },
                { title: '实训名称', key: 'trainingName', align: 'center', width: 200 },
                { title: '考试起止时间', key: 'time', align: 'center' },
                { title: '报关单', key: 'customsScore', align: 'center' },
                { title: '核注清单', key: 'nuclearScore', align: 'center' },
                { title: '公路舱单', key: 'roadManifestScore', align: 'center' },
                { title: '突发事件', key: 'emergencyScore', align: 'center' },
                { title: '总得分', key: 'scores', align: 'center' },
                { title: '操作', slot: 'action', align: 'center', width: 160 }
            ])
        }
    },
    mounted () {
        this.queryList()
    },
    methods: {

        search () {
            this.params.pageNum = 1
            this.queryList()
        },
        ckTrain (row) {
            this.$router.push({
                path: `/training/${row.id}`
            })
        },
        queryList () {
            let params = {
                trainingName: this.params.trainingName,
                pageNum: this.params.pageNum,
                pageSize: this.params.pageSize
            }
            trainGradeList(params).then(res => {
                if (res.data.code != '0000') {
                    this.$Message(res.data.data)
                    return
                }
                this.list = res.data.data.list
                this.params.total = res.data.data.total
            })
        }

    }
}
</script>
<style lang="less" scoped>
.grade-top{
    height:40px;
    line-height: 40px;
    span{
        margin-right:50px;
    }
}
</style>
